package hotel.switchs.oversea.biz.service.impl;

import com.alibaba.fastjson.JSON;
import hotel.base.oversea.constant.CommonConstants;
import hotel.base.oversea.constant.SwitchConstants;
import hotel.base.oversea.service.impl.BaseServiceImpl;
import hotel.base.oversea.utils.JSONUtils;
import hotel.base.oversea.utils.Result;
import hotel.base.oversea.vo.ResultStatusByFlexVo;
import hotel.base.oversea.vo.ResultStatusInfoVo;
import hotel.base.oversea.vo.ResultStatusVo;
import hotel.switchs.oversea.api.VO.*;
import hotel.switchs.oversea.api.VO.request.SupplierTimeSaleInfoVo;
import hotel.switchs.oversea.api.entity.SwitchHotelAavailableProperties;
import hotel.switchs.oversea.api.entity.SwitchHotelInfo;
import hotel.switchs.oversea.api.entity.SwitchHotelOrderTypeInfo;
import hotel.switchs.oversea.biz.config.service.RedisService;
import hotel.switchs.oversea.biz.mapper.SwitchHoteAavailablePropertieslMapper;
import hotel.switchs.oversea.biz.mapper.SwitchHotelInfoMapper;
import hotel.switchs.oversea.biz.mapper.SwitchHotelOrderTypeInfoMapper;
import hotel.switchs.oversea.biz.service.SwitchSubHotelInfoService;
import hotel.switchs.oversea.biz.utils.SwitchsHttpUtils;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.*;

/**
 * @Author lmf
 * @Date 2020/5/15 10:17
 **/
@Service
public class SwitchSubHotelInfoServiceImpl extends BaseServiceImpl implements SwitchSubHotelInfoService {
    Logger logger= LoggerFactory.getLogger(SwitchSubHotelInfoServiceImpl.class);
    @Value("${profile.type}")
    private String profile;
    @Autowired
    private SwitchHotelInfoMapper switchHotelInfoMapper;
    @Autowired
    private SwitchHotelOrderTypeInfoMapper switchHotelOrderTypeInfoMapper;
    @Autowired
    private SwitchHoteAavailablePropertieslMapper switchHoteAavailablePropertieslMapper;
    @Autowired
    private RedisService redisService;
    @Autowired
    private RedisTemplate redisTemplate;
    /**
     * 创建子酒店
     * @param masterHotelIDs 母酒店id
     * @return
     */
    @Override
    @Retryable(value = Exception.class,maxAttempts = 4,backoff = @Backoff(delay = 2000,multiplier = 1.5))
    public Result<Object> createSubHoltel(Integer[] masterHotelIDs) {
        Map<String, Object> data = new HashMap<>();
        data.put("masterHotelIDs",masterHotelIDs);
        String result= SwitchsHttpUtils.sendRequest(data,"createsubhotel",profile);
        //对结构进行格式化
        JSONObject jsonObject = JSONObject.fromObject(result);
        ResultStatusByFlexVo resultStatusByFlexVo= JSON.parseObject(result,ResultStatusByFlexVo.class);
        ResultStatusVo resultStatusVo=resultStatusByFlexVo.getResultStatus();
        if(resultStatusVo.getResultCode()!=0){
            logger.info("创建子酒店错误信息{}",resultStatusVo.getResultMsg());
            return new Result<>(resultStatusVo.getResultMsg(), CommonConstants.REQUEST_ERROR);
        }
       /* ResultStatusInfoVo resultStatusInfoVo= JSONUtils.toBean(jsonObject.getJSONObject("resultStatus"),ResultStatusInfoVo.class);
        //说明调用接口失败
        if(resultStatusInfoVo.getResultCode()==4){
            ResultStatusInfoByJsonVo resultStatusInfoByJsonVo = JSONUtils.toBean(jsonObject.getJSONObject("resultStatus"), ResultStatusInfoByJsonVo.class);
            logger.info("新增子物理房型错误信息{}", resultStatusInfoVo.getResultMsg());
            return new Result<>(resultStatusInfoByJsonVo.getResultMsg().toString(), CommonConstants.REQUEST_ERROR);
        }
        if(resultStatusInfoVo.getResultCode()!=0){
            logger.info("创建子酒店错误信息{}",resultStatusInfoVo.getResultMsg());
            return new Result<>(resultStatusInfoVo.getResultMsg(), CommonConstants.REQUEST_ERROR);
        }*/
        //遍历获取创建成功返回的子酒店id
        JSONArray hotelIDs=jsonObject.getJSONArray("hotelIDs");
        Integer[] list=new Integer[hotelIDs.size()];
        for (int i=0;i<hotelIDs.size();i++){
            list[i]=hotelIDs.getInt(i);
        }
        return new Result<>(list);
    }
    /**
     * 获取子酒店列表
     * param 请求的参数列表
     */
    @Retryable(value = Exception.class,maxAttempts = 4,backoff = @Backoff(delay = 2000,multiplier = 1.5))
    public Result<Object> getStuHotelList(int pageSize,int pageIndex,Map<String,Object> param){
        Map<String, Object> data = new HashMap<>();
        Map<String,Object> pager=new HashMap<>();
        data.putAll(param);
        pager.put("pageSize",pageSize);
        pager.put("pageIndex",pageIndex);
        pager.put("isReturnTotalCount",true);
        data.put("pager",pager);
        String result= SwitchsHttpUtils.sendRequest(data,"getdlthotellist",profile);
        //对结构进行格式化
        JSONObject jsonObject = JSONObject.fromObject(result);
        System.out.println(result);
        ResultStatusInfoVo resultStatusInfoVo= JSONUtils.toBean(jsonObject.getJSONObject("resultStatus"),ResultStatusInfoVo.class);
        //说明调用接口失败
        if(resultStatusInfoVo.getResultCode()!=0){
            logger.info("获取子酒店列表错误信息{}",resultStatusInfoVo.getResultMsg());
            return new Result<>(resultStatusInfoVo.getResultMsg(), CommonConstants.REQUEST_ERROR);
        }
        List<DltHotelEntityVo> switchHotelInfoVos;
        try{
            //格式化子酒店相关信息
            String dltHotelEntityListStr = jsonObject.getString("dltHotelEntityList");
            dltHotelEntityListStr = dltHotelEntityListStr.replace(":null,",":\"\",");
            switchHotelInfoVos= JSON.parseObject(dltHotelEntityListStr,List.class);
        }catch (Exception e){
            logger.error("格式化子酒店相关信息异常，{}",result);
            return new Result<>(e.getMessage(),CommonConstants.PARSE_ERROR);
        }
        if(switchHotelInfoVos.size()<0) return new Result<>();

        PagerVo pagerVo=JSONUtils.toBean(jsonObject.getJSONObject("pager"), PagerVo.class);
        GetDltHotelListVo getDltHotelListVo=new GetDltHotelListVo();
        getDltHotelListVo.setDltHotelEntityList(switchHotelInfoVos);
        getDltHotelListVo.setPager(pagerVo);
        return new Result<>(getDltHotelListVo);
    }

    /**
     * 定时器保存多个子酒店数据
     * @param switchHotelInfoVosMap
     * @return
     */
    @Override
    public Result<Object> saveHotelInfos(Map<String,List<DltHotelEntityVo>> switchHotelInfoVosMap){
        //判断缓存是否已经有子酒店的数据
       /* Map<String,DltHotelEntityVo>  dltHotelEntityVos=new HashMap<>();
        if(!ObjectUtils.isEmpty( redisService.get(SwitchConstants.SWITCH_HOTELS_STU_HOTEL_INFO))){
            dltHotelEntityVos=(Map<String,DltHotelEntityVo>) redisService.get(SwitchConstants.SWITCH_HOTELS_STU_HOTEL_INFO);
        }*/
        for (Map.Entry<String,List<DltHotelEntityVo>> entry:switchHotelInfoVosMap.entrySet()) {
            List<DltHotelEntityVo> switchHotelInfoVos = entry.getValue();
            //封装子酒店对应的表单数据
            List<SwitchHotelOrderTypeInfo> switchHotelOrderTypeInfos=new ArrayList<>();
            List<SwitchHotelInfo> switchHotelInfos=new ArrayList<>();
            //缓存保存酒店id数据，接口业务需要参数：key= subHotelId，value= masterHotelid
            Map<String,String> redisChildHotelIdsMap = new HashMap<>();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i <switchHotelInfoVos.size(); i++) {
                DltHotelEntityVo dltCoordinateEntityVo = switchHotelInfoVos.get(i);
                SwitchHotelInfo switchHotelInfo=new SwitchHotelInfo();
                switchHotelInfo.setHotelId(dltCoordinateEntityVo.getHotelID());
                /*if(!ObjectUtils.isEmpty(switchHotelInfoMapper.selectOne(switchHotelInfo))){
                    continue;
                }*/
                //保存redis的map集合
               // dltHotelEntityVos.put(String.valueOf(dltCoordinateEntityVo.getHotelID()),dltCoordinateEntityVo);
                String hote_id=String.valueOf(UUID.randomUUID());
                switchHotelInfo.setState(0);
                switchHotelInfo.setCreateTime(new Date());
                switchHotelInfo.setModifyTime(new Date());
                switchHotelInfo.setId(hote_id);
                switchHotelInfo.setCityId(dltCoordinateEntityVo.getCityID());
                switchHotelInfo.setCityName(dltCoordinateEntityVo.getCityName());
                switchHotelInfo.setHotelEName(dltCoordinateEntityVo.getHotelEName());
                switchHotelInfo.setHotelName(dltCoordinateEntityVo.getHotelName());
                switchHotelInfo.setMasterHotelId(dltCoordinateEntityVo.getMasterHotelID());
                switchHotelInfo.setChannelaBookable(dltCoordinateEntityVo.getChannelaBookable());
                switchHotelInfo.setB2bBookable(dltCoordinateEntityVo.getB2bBookable());
                switchHotelInfo.setQReserveDay(dltCoordinateEntityVo.getQReserveDay());
                switchHotelInfo.setCBookable(dltCoordinateEntityVo.getCBookable());
                switchHotelInfo.setQBookable(dltCoordinateEntityVo.getQBookable());
                switchHotelInfo.setCReserveDay(dltCoordinateEntityVo.getCReserveDay());
                switchHotelInfo.setCReserveTime(dltCoordinateEntityVo.getCReserveTime());
                switchHotelInfo.setQReserveTime(dltCoordinateEntityVo.getQReserveTime());
                switchHotelInfos.add(switchHotelInfo);

                redisChildHotelIdsMap.put(String.valueOf(switchHotelInfo.getHotelId()),String.valueOf(switchHotelInfo.getMasterHotelId()));
                sb.append("'"+switchHotelInfo.getHotelId()+"'");//拼接单引号,到数据库后台用in查询.
                if(i!=switchHotelInfoVos.size()-1){
                    sb.append(",");
                }

                IssueOrderTypeInfoVo issueOrderTypeInfoVo=dltCoordinateEntityVo.getIssueOrderTypeInfo();
                if(!ObjectUtils.isEmpty(issueOrderTypeInfoVo)){
                    SwitchHotelOrderTypeInfo switchHotelOrderTypeInfo=new SwitchHotelOrderTypeInfo();
                    //BeanUtil.copyPropertiesIgnoreCase(switchHotelOrderTypeInfo,issueOrderTypeInfoVo);
                    switchHotelOrderTypeInfo.setHotelId(issueOrderTypeInfoVo.getHotelID());

                    switchHotelOrderTypeInfo.setHotelPId(hote_id);
                    switchHotelOrderTypeInfo.setState(0);
                    switchHotelOrderTypeInfo.setId(String.valueOf(UUID.randomUUID()));
                    switchHotelOrderTypeInfo.setCreateTime(new Date());
                    switchHotelOrderTypeInfo.setModifyTime(new Date());
                    switchHotelOrderTypeInfo.setIssueType(issueOrderTypeInfoVo.getIssueType());
                    switchHotelOrderTypeInfo.setSendOrderEmail(issueOrderTypeInfoVo.getSendOrderEmail());
                    switchHotelOrderTypeInfo.setSendOrderName(issueOrderTypeInfoVo.getSendOrderName());
                    switchHotelOrderTypeInfo.setFaxFormatNo(issueOrderTypeInfoVo.getFaxFormatNo());
                    switchHotelOrderTypeInfo.setFax(issueOrderTypeInfoVo.getFax());
                    switchHotelOrderTypeInfo.setEmail(issueOrderTypeInfoVo.getEmail());
                    switchHotelOrderTypeInfo.setSettlementCycle(issueOrderTypeInfoVo.getSettlementCycle());
                    switchHotelOrderTypeInfo.setIsAutoSend(issueOrderTypeInfoVo.getIsAutoSend());
                    switchHotelOrderTypeInfo.setIsAutoReceive(issueOrderTypeInfoVo.getIsAutoReceive());
                    switchHotelOrderTypeInfo.setIsAutoReject(issueOrderTypeInfoVo.getIsAutoReject());
                    switchHotelOrderTypeInfo.setAutoSendLanguage(issueOrderTypeInfoVo.getAutoSendLanguage());
                    switchHotelOrderTypeInfo.setCancelAutoSend(issueOrderTypeInfoVo.getCancelAutoSend());
                    switchHotelOrderTypeInfo.setIsAutoSendPms(issueOrderTypeInfoVo.getIsAutoSendPMS());
                    switchHotelOrderTypeInfo.setSupplierId(issueOrderTypeInfoVo.getSupplierId());
                    switchHotelOrderTypeInfo.setContractNo(issueOrderTypeInfoVo.getContractNo());
                    switchHotelOrderTypeInfo.setSendPriceOption(issueOrderTypeInfoVo.getSendPriceOption());
                    switchHotelOrderTypeInfo.setSendAttachRemark(issueOrderTypeInfoVo.getSendAttachRemark());
                    switchHotelOrderTypeInfo.setIsVcrsAutoSend(issueOrderTypeInfoVo.getIsVcrsAutoSend());
                    switchHotelOrderTypeInfo.setIsVcrsAutoRecive(issueOrderTypeInfoVo.getIsVcrsAutoRecive());
                    switchHotelOrderTypeInfo.setIsBlackMasterHotel(issueOrderTypeInfoVo.getIsBlackMasterHotel());
                    switchHotelOrderTypeInfo.setIsBlackSupplier(issueOrderTypeInfoVo.getIsBlackSupplier());
                    switchHotelOrderTypeInfo.setIsBlackHotel(issueOrderTypeInfoVo.getIsBlackHotel());
                    switchHotelOrderTypeInfo.setSendOrderCurrency(issueOrderTypeInfoVo.getSendOrderCurrency());
                    switchHotelOrderTypeInfos.add(switchHotelOrderTypeInfo);

                }
            }
            //旧数据删除，插入新数据
            Map idsMap = new HashMap();
            idsMap.put("ids",sb.toString());
            if(-1!=switchHotelInfoMapper.deleteBatch(idsMap)){
                switchHotelInfoMapper.insertList(switchHotelInfos);
            }

            //子酒店的整体信息缓存 （key,list）
            // redisService.set(SwitchConstants.SWITCH_HOTELS_STU_HOTEL_INFO,dltHotelEntityVos);

            //子酒店ids缓存  key=hotelId value=masterHotelId
            Map<String,String> getRedisChildHotelIdsMap = (Map<String,String>)redisTemplate.opsForValue().get(SwitchConstants.REDIS_SWITCH_HOTEL_CHILD_IDS);
            if(null != getRedisChildHotelIdsMap && getRedisChildHotelIdsMap.size()>0){
                getRedisChildHotelIdsMap.putAll(redisChildHotelIdsMap);
            }else{
                getRedisChildHotelIdsMap=redisChildHotelIdsMap;
            }
            redisTemplate.opsForValue().set(SwitchConstants.REDIS_SWITCH_HOTEL_CHILD_IDS,getRedisChildHotelIdsMap);

            if(switchHotelOrderTypeInfos.size()>0){
                //删除旧数据，保存新数据
                if(-1!=switchHotelOrderTypeInfoMapper.deleteBatch(idsMap)){
                    switchHotelOrderTypeInfoMapper.insertList(switchHotelOrderTypeInfos);
                }
            }
        }
        return new Result<>();
    }
    /**
     * 保存子酒店数据 根据list集合对象
     * @return
     */
    @Override
    public Result<Object> saveHotelInfoOne(List<DltHotelEntityVo> switchHotelInfoVos){
        //封装子酒店对应的表单数据
        List<SwitchHotelOrderTypeInfo> switchHotelOrderTypeInfos=new ArrayList<>();
        List<SwitchHotelInfo> switchHotelInfos=new ArrayList<>();
        //缓存保存酒店id数据，接口业务需要参数：key= subHotelId，value= masterHotelid
        Map<String,String> redisChildHotelIdsMap = new HashMap<>();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i <switchHotelInfoVos.size(); i++) {
            DltHotelEntityVo dltCoordinateEntityVo = switchHotelInfoVos.get(i);
            SwitchHotelInfo switchHotelInfo=new SwitchHotelInfo();
            switchHotelInfo.setHotelId(dltCoordinateEntityVo.getHotelID());
                /*if(!ObjectUtils.isEmpty(switchHotelInfoMapper.selectOne(switchHotelInfo))){
                    continue;
                }*/
            //保存redis的map集合
            // dltHotelEntityVos.put(String.valueOf(dltCoordinateEntityVo.getHotelID()),dltCoordinateEntityVo);
            String hote_id=String.valueOf(UUID.randomUUID());
            switchHotelInfo.setState(0);
            switchHotelInfo.setCreateTime(new Date());
            switchHotelInfo.setModifyTime(new Date());
            switchHotelInfo.setId(hote_id);
            switchHotelInfo.setCityId(dltCoordinateEntityVo.getCityID());
            switchHotelInfo.setCityName(dltCoordinateEntityVo.getCityName());
            switchHotelInfo.setHotelEName(dltCoordinateEntityVo.getHotelEName());
            switchHotelInfo.setHotelName(dltCoordinateEntityVo.getHotelName());
            switchHotelInfo.setMasterHotelId(dltCoordinateEntityVo.getMasterHotelID());
            switchHotelInfo.setChannelaBookable(dltCoordinateEntityVo.getChannelaBookable());
            switchHotelInfo.setB2bBookable(dltCoordinateEntityVo.getB2bBookable());
            switchHotelInfo.setQReserveDay(dltCoordinateEntityVo.getQReserveDay());
            switchHotelInfo.setCBookable(dltCoordinateEntityVo.getCBookable());
            switchHotelInfo.setQBookable(dltCoordinateEntityVo.getQBookable());
            switchHotelInfo.setCReserveDay(dltCoordinateEntityVo.getCReserveDay());
            switchHotelInfo.setCReserveTime(dltCoordinateEntityVo.getCReserveTime());
            switchHotelInfo.setQReserveTime(dltCoordinateEntityVo.getQReserveTime());
            switchHotelInfos.add(switchHotelInfo);

            redisChildHotelIdsMap.put(String.valueOf(switchHotelInfo.getHotelId()),String.valueOf(switchHotelInfo.getMasterHotelId()));
            sb.append("'"+switchHotelInfo.getHotelId()+"'");//拼接单引号,到数据库后台用in查询.
            if(i!=switchHotelInfoVos.size()-1){
                sb.append(",");
            }

            IssueOrderTypeInfoVo issueOrderTypeInfoVo=dltCoordinateEntityVo.getIssueOrderTypeInfo();
            if(!ObjectUtils.isEmpty(issueOrderTypeInfoVo)){
                SwitchHotelOrderTypeInfo switchHotelOrderTypeInfo=new SwitchHotelOrderTypeInfo();
                //BeanUtil.copyPropertiesIgnoreCase(switchHotelOrderTypeInfo,issueOrderTypeInfoVo);
                switchHotelOrderTypeInfo.setHotelId(issueOrderTypeInfoVo.getHotelID());

                switchHotelOrderTypeInfo.setHotelPId(hote_id);
                switchHotelOrderTypeInfo.setState(0);
                switchHotelOrderTypeInfo.setId(String.valueOf(UUID.randomUUID()));
                switchHotelOrderTypeInfo.setCreateTime(new Date());
                switchHotelOrderTypeInfo.setModifyTime(new Date());
                switchHotelOrderTypeInfo.setIssueType(issueOrderTypeInfoVo.getIssueType());
                switchHotelOrderTypeInfo.setSendOrderEmail(issueOrderTypeInfoVo.getSendOrderEmail());
                switchHotelOrderTypeInfo.setSendOrderName(issueOrderTypeInfoVo.getSendOrderName());
                switchHotelOrderTypeInfo.setFaxFormatNo(issueOrderTypeInfoVo.getFaxFormatNo());
                switchHotelOrderTypeInfo.setFax(issueOrderTypeInfoVo.getFax());
                switchHotelOrderTypeInfo.setEmail(issueOrderTypeInfoVo.getEmail());
                switchHotelOrderTypeInfo.setSettlementCycle(issueOrderTypeInfoVo.getSettlementCycle());
                switchHotelOrderTypeInfo.setIsAutoSend(issueOrderTypeInfoVo.getIsAutoSend());
                switchHotelOrderTypeInfo.setIsAutoReceive(issueOrderTypeInfoVo.getIsAutoReceive());
                switchHotelOrderTypeInfo.setIsAutoReject(issueOrderTypeInfoVo.getIsAutoReject());
                switchHotelOrderTypeInfo.setAutoSendLanguage(issueOrderTypeInfoVo.getAutoSendLanguage());
                switchHotelOrderTypeInfo.setCancelAutoSend(issueOrderTypeInfoVo.getCancelAutoSend());
                switchHotelOrderTypeInfo.setIsAutoSendPms(issueOrderTypeInfoVo.getIsAutoSendPMS());
                switchHotelOrderTypeInfo.setSupplierId(issueOrderTypeInfoVo.getSupplierId());
                switchHotelOrderTypeInfo.setContractNo(issueOrderTypeInfoVo.getContractNo());
                switchHotelOrderTypeInfo.setSendPriceOption(issueOrderTypeInfoVo.getSendPriceOption());
                switchHotelOrderTypeInfo.setSendAttachRemark(issueOrderTypeInfoVo.getSendAttachRemark());
                switchHotelOrderTypeInfo.setIsVcrsAutoSend(issueOrderTypeInfoVo.getIsVcrsAutoSend());
                switchHotelOrderTypeInfo.setIsVcrsAutoRecive(issueOrderTypeInfoVo.getIsVcrsAutoRecive());
                switchHotelOrderTypeInfo.setIsBlackMasterHotel(issueOrderTypeInfoVo.getIsBlackMasterHotel());
                switchHotelOrderTypeInfo.setIsBlackSupplier(issueOrderTypeInfoVo.getIsBlackSupplier());
                switchHotelOrderTypeInfo.setIsBlackHotel(issueOrderTypeInfoVo.getIsBlackHotel());
                switchHotelOrderTypeInfo.setSendOrderCurrency(issueOrderTypeInfoVo.getSendOrderCurrency());
                switchHotelOrderTypeInfos.add(switchHotelOrderTypeInfo);

            }
        }
        //旧数据删除，插入新数据
        Map idsMap = new HashMap();
        idsMap.put("ids",sb.toString());
        if(-1!=switchHotelInfoMapper.deleteBatch(idsMap)){
            switchHotelInfoMapper.insertList(switchHotelInfos);
        }
        return new Result<>();
    }


    /**
     * 设置子酒店售卖渠道
     */
    @Retryable(value = Exception.class,maxAttempts = 4,backoff = @Backoff(delay = 2000,multiplier = 1.5))
    public Result<Object>  setHotelSupplierBookable(Map<String,Object> param, List<SupplierTimeSaleInfoVo> supplierTimeSaleInfoList){
        Map<String, Object> data = new HashMap<>();
        data.putAll(param);
        if(supplierTimeSaleInfoList.size()>0){
            data.put("supplierTimeSaleInfoList",supplierTimeSaleInfoList);
        }
        String result= SwitchsHttpUtils.sendRequest(data,"updatesupplierhotelbookablebybooktype",profile);
        //对结构进行格式化
        JSONObject jsonObject = JSONObject.fromObject(result);
        ResultStatusInfoVo resultStatusInfoVo= JSONUtils.toBean(jsonObject.getJSONObject("resultStatus"),ResultStatusInfoVo.class);
        if(resultStatusInfoVo.getResultCode()!=0){
            return new Result<>(resultStatusInfoVo.getResultMsg());
        }
        return new Result<>();
    }
    /**
     * 设置子酒店最晚预定时间
     */
    @Retryable(value = Exception.class,maxAttempts = 4,backoff = @Backoff(delay = 2000,multiplier = 1.5))
    public Result<Object> setDhotelReServeTime(Map<String,Object> param){
        Map<String, Object> data = new HashMap<>();
        data.putAll(param);
        String result= SwitchsHttpUtils.sendRequest(data,"setdlthotelreservetime",profile);
        JSONObject jsonObject = JSONObject.fromObject(result);
        ResultStatusInfoVo resultStatusInfoVo= JSONUtils.toBean(jsonObject.getJSONObject("resultStatus"),ResultStatusInfoVo.class);
        if(resultStatusInfoVo.getResultCode()!=0){
            return new Result<>(resultStatusInfoVo.getResultMsg());
        }
        return new Result<>();
    }
    /**
     * 获取子酒店可用属性信息
     */
    @Retryable(value = Exception.class,maxAttempts = 4,backoff = @Backoff(delay = 2000,multiplier = 1.5))
    public Result<Object> getHotelAvailableProperties(Integer hotelId){
        Map<String, Object> data = new HashMap<>();
        data.put("hotelId",hotelId);
        String result= SwitchsHttpUtils.sendRequest(data,"getHotelAvailableProperties",profile);
        //对结构进行格式化
        JSONObject jsonObject = JSONObject.fromObject(result);
        ResultStatusInfoVo resultStatusInfoVo= JSONUtils.toBean(jsonObject.getJSONObject("resultStatus"),ResultStatusInfoVo.class);
        if(resultStatusInfoVo.getResultCode()!=0){
            logger.info("获取子酒店可用属性值信息错误信息{}",resultStatusInfoVo.getResultMsg());
            return new Result<>(resultStatusInfoVo.getResultMsg());
        }
        List<ApplicabilityRatePropertyValueVo> list=JSONUtils.toList(jsonObject.getJSONArray("applicabilityRatePropertyValueList"), ApplicabilityRatePropertyValueVo.class);
        if(list.size()==0){
            return null;
        }
        //封装属性表单数据
        List<SwitchHotelAavailableProperties> hoteAavailablePropertiesls=new ArrayList<>();
        for(ApplicabilityRatePropertyValueVo applicabilityRatePropertyValueVo:list){
            SwitchHotelAavailableProperties switchHoteAavailablePropertiesl=new SwitchHotelAavailableProperties();
            switchHoteAavailablePropertiesl.setHotelid(hotelId);
            switchHoteAavailablePropertiesl.setRateCode(applicabilityRatePropertyValueVo.getRateCode());
            if(!ObjectUtils.isEmpty(switchHoteAavailablePropertieslMapper.selectOne(switchHoteAavailablePropertiesl))){
                continue;
            }
            switchHoteAavailablePropertiesl.setId(String.valueOf(UUID.randomUUID()));
            switchHoteAavailablePropertiesl.setRateCodeyLabel(applicabilityRatePropertyValueVo.getRateCodeyLabel());
            hoteAavailablePropertiesls.add(switchHoteAavailablePropertiesl);
        }
        if(hoteAavailablePropertiesls.size()>0){
            switchHoteAavailablePropertieslMapper.insertList(hoteAavailablePropertiesls);
        }
        return new Result<>(list);
    }

    @Override
    public Result<Object> queryPageIds(int index, int pageSize) {
        Map<String,Integer> map = new HashMap();
        map.put("index",index);
        map.put("pageSize",pageSize);
        return new Result<>(switchHotelInfoMapper.queryPageDto(map));
    }
}
